<?php
class LiWEConfig
{
	public function __construct ( $base_dir = "./site", $cfg_name = "liwe.json" )
	{
		$this->name = $base_dir . "/" . $cfg_name;
		$this->data = array ();
	}
	
	public function get ( $name, $def_val = null )
	{
		if ( array_key_exists( $name, $this->data ) ) return $this->data [ $name ];
		
		return $def_val;
	}
	
	public function has_key ( $key )
	{
		return array_key_exists($key, $this->data );
	}
	
	private function _read ()
	{
		$txt = file_get_contents ( $this->name );
		$this->data = json_decode ( $txt, true );
	}
}
